<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<head>
    <base href="<%=basePath%>"/>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>我不是真正的慕课网</title>
    <link rel="stylesheet" type="text/css" href="styles/simditor.css"/>

    <script type="text/javascript" src="scripts/jquery.min.js"></script>
    <script type="text/javascript" src="scripts/module.min.js"></script>
    <script type="text/javascript" src="scripts/hotkeys.min.js"></script>
    <script type="text/javascript" src="scripts/uploader.min.js"></script>
    <script type="text/javascript" src="scripts/simditor.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            //初始化文本编辑器
            var editor = new Simditor({
                //textarea的id
                textarea: $('#editor'),
                placeholder: '请输入内容Balabala...',
                pasteImage: true,
                defaultImage: 'images/image.png',
                //工具条都包含哪些内容
                toolbar: ['title', 'bold', 'italic', 'underline', 'strikethrough', 'fontScale', 'color', 'ol', 'ul', 'blockquote', 'code', 'table', 'link', 'image', 'hr', 'indent', 'outdent', 'alignment'],
                //若需要上传功能，上传的参数设置。
                upload: {
                    url: 'manage/product/rich_text_upload.do', //文件上传的接口地址
                    params: null, //键值对,指定文件上传接口的额外参数,上传的时候随文件一起提交
                    fileKey: 'file', //服务器端获取文件数据的参数名
                    connectionCount: 3,
                    leaveConfirm: '正在上传文件'
                }
            });
        });
    </script>
</head>
<body>
<div align="center">
    <h1>Spring MVC上传附件</h1>
    <form method="post" action="manage/product/upload.do" enctype="multipart/form-data">
        <input type="file" name="file"/>
        <input type="submit"/><br/><br/>
        <img src="http://img.happymmall.com/${file}" alt="上传图片" width="300px"/>
    </form>
    <hr/>
    <h1>富文本simditor上传图片</h1>
    <form method="post" action="manage/product/rich_text_upload.do" enctype="multipart/form-data">
        <div>
            <input type="file" name="file"/>
            <input type="submit"/>
        </div>
        <br/>
        <a href="index.jsp"><img src="gem.jpg" width="300px"/> </a>
    </form>
</div>
<form method="post" action="view.do">
    <textarea id="editor" name="editor"></textarea>
    <div align="center"><input type="submit" style="height: 40px;width: 60px"></div>
</form>
</body>
</html>
